
package com.epam.android.training.day4day5.task1;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TextView;

/**
 * Support activity of task1 application which shows greeting message.
 * 
 * @author Anton Novikau
 */
public class SupportActivity extends Activity {

    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.support);

        Bundle data = getIntent().getExtras();
        Resources resources = getResources();

        TextView greetingView = (TextView) findViewById(R.id.greeting);
        String greeting = ResourcesUtil.formatGreeting(resources, data);
        greetingView.setText(greeting);

        int age = data.getInt(resources.getString(R.string.age_bundle_key));

        if (age > 0) {
            TextView ageTextView = (TextView) findViewById(R.id.age_text);
            ageTextView.setText(ResourcesUtil.formatAgeMessage(resources, age));
            ageTextView.setVisibility(TextView.VISIBLE);
        }
    }
}
